﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRExtDocumentDataResponse", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRExtDocumentDataResponse))]
    public class RRExtDocumentDataResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRExtDocumentDataResponse clazz;
        
        public RRExtDocumentDataResponseSerializer(IRRExtDocumentDataResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Isikud");
            if (clazz.Isikud!=null) {
                global::Xtee.Core.SerializationMetadata metaIsikud = this.GetMetaData(clazz.Isikud);
                Writer.WriteTypeAttribute(metaIsikud.TypeQualifiedName.Namespace, metaIsikud.TypeQualifiedName.Name);
                metaIsikud.NewSerializer(clazz.Isikud).WriteXml(Writer);
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikud");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Isikud") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRExtDocumentDataResponse>Isikud");
                }
                global::Xtee.Core.SerializationMetadata metaIsikud = this.GetMetaData<RRExtDocumentDataResponse.IIsikudType>(Reader, ">>RRExtDocumentDataResponse>Isikud", "http://producers.rr.xtee.riik.ee/producer/rr");
                clazz.Isikud = metaIsikud.NewEntity<RRExtDocumentDataResponse.IIsikudType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("Isikud");
                    metaIsikud.NewSerializer(clazz.Isikud).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRExtDocumentDataResponse>Isikud", Reader.LocalName);
            }
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>RRExtDocumentDataResponse>Isikud", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRExtDocumentDataResponse.IsikudType))]
        public class IsikudTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected RRExtDocumentDataResponse.IIsikudType clazz;
            
            public IsikudTypeSerializer(RRExtDocumentDataResponse.IIsikudType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                Writer.WriteStartElement("Isik");
                if (clazz.Isik!=null) {
                    global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData(clazz.Isik);
                    Writer.WriteTypeAttribute(metaIsik.TypeQualifiedName.Namespace, metaIsik.TypeQualifiedName.Name);
                    metaIsik.NewSerializer(clazz.Isik).WriteXml(Writer);
                }
                else {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isik");
                }
                Writer.WriteEndElement();
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="Isik") {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>RRExtDocumentDataResponse>Isikud>Isik");
                    }
                    global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData<RRExtDocumentDataResponse.IsikudType.IIsikType>(Reader, ">>>RRExtDocumentDataResponse>Isikud>Isik", "http://producers.rr.xtee.riik.ee/producer/rr");
                    clazz.Isik = metaIsik.NewEntity<RRExtDocumentDataResponse.IsikudType.IIsikType>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("Isik");
                        metaIsik.NewSerializer(clazz.Isik).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>RRExtDocumentDataResponse>Isikud>Isik", Reader.LocalName);
                }
            }
            
            [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>RRExtDocumentDataResponse>Isikud>Isik", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRExtDocumentDataResponse.IsikudType.IsikType))]
            public class IsikTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
                
                protected RRExtDocumentDataResponse.IsikudType.IIsikType clazz;
                
                public IsikTypeSerializer(RRExtDocumentDataResponse.IsikudType.IIsikType clazz) {
                    this.clazz = clazz;
                }
                
                public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                    base.WriteXml(Writer);
                    Writer.WriteStartElement("Isikukood");
                    if (clazz.Isikukood!=null) {
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
                    }
                    Writer.WriteEndElement();
                    Writer.WriteStartElement("Eesnimi");
                    if (clazz.Eesnimi!=null) {
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Eesnimi");
                    }
                    Writer.WriteEndElement();
                    Writer.WriteStartElement("Perenimi");
                    if (clazz.Perenimi!=null) {
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perenimi))).ToString());
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Perenimi");
                    }
                    Writer.WriteEndElement();
                    Writer.WriteStartElement("vead");
                    if (clazz.Vead!=null) {
                        global::Xtee.Core.SerializationMetadata metaVead = this.GetMetaData(clazz.Vead);
                        Writer.WriteTypeAttribute(metaVead.TypeQualifiedName.Namespace, metaVead.TypeQualifiedName.Name);
                        metaVead.NewSerializer(clazz.Vead).WriteXml(Writer);
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vead");
                    }
                    Writer.WriteEndElement();
                }
                
                public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                    base.ReadXml(Reader);
                    if (Reader.LocalName=="Isikukood") {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RRExtDocumentDataResponse>Isikud>Isik>Isikukood");
                        }
                        clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukood")).Value;
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RRExtDocumentDataResponse>Isikud>Isik>Isikukood", Reader.LocalName);
                    }
                    if (Reader.LocalName=="Eesnimi") {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RRExtDocumentDataResponse>Isikud>Isik>Eesnimi");
                        }
                        clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Eesnimi")).Value;
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RRExtDocumentDataResponse>Isikud>Isik>Eesnimi", Reader.LocalName);
                    }
                    if (Reader.LocalName=="Perenimi") {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RRExtDocumentDataResponse>Isikud>Isik>Perenimi");
                        }
                        clazz.Perenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Perenimi")).Value;
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RRExtDocumentDataResponse>Isikud>Isik>Perenimi", Reader.LocalName);
                    }
                    if (Reader.LocalName=="vead") {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>RRExtDocumentDataResponse>Isikud>Isik>vead");
                        }
                        global::Xtee.Core.SerializationMetadata metaVead = this.GetMetaData<RRExtDocumentDataResponse.IsikudType.IsikType.IVeadType>(Reader, ">>>>RRExtDocumentDataResponse>Isikud>Isik>vead", "http://producers.rr.xtee.riik.ee/producer/rr");
                        clazz.Vead = metaVead.NewEntity<RRExtDocumentDataResponse.IsikudType.IsikType.IVeadType>();
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("vead");
                            metaVead.NewSerializer(clazz.Vead).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>RRExtDocumentDataResponse>Isikud>Isik>vead", Reader.LocalName);
                    }
                }
                
                [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>>RRExtDocumentDataResponse>Isikud>Isik>vead", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRExtDocumentDataResponse.IsikudType.IsikType.VeadType))]
                public class VeadTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
                    
                    protected RRExtDocumentDataResponse.IsikudType.IsikType.IVeadType clazz;
                    
                    public VeadTypeSerializer(RRExtDocumentDataResponse.IsikudType.IsikType.IVeadType clazz) {
                        this.clazz = clazz;
                    }
                    
                    public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                        base.WriteXml(Writer);
                        Writer.WriteStartElement("viga");
                        if (clazz.Viga!=null) {
                            global::Xtee.Core.SerializationMetadata metaViga = this.GetMetaData(clazz.Viga);
                            Writer.WriteTypeAttribute(metaViga.TypeQualifiedName.Namespace, metaViga.TypeQualifiedName.Name);
                            metaViga.NewSerializer(clazz.Viga).WriteXml(Writer);
                        }
                        else {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Viga");
                        }
                        Writer.WriteEndElement();
                    }
                    
                    public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                        base.ReadXml(Reader);
                        if (Reader.LocalName=="viga") {
                            if (Reader.IsElementNil()) {
                                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga");
                            }
                            global::Xtee.Core.SerializationMetadata metaViga = this.GetMetaData<RRExtDocumentDataResponse.IsikudType.IsikType.VeadType.IVigaType>(Reader, ">>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga", "http://producers.rr.xtee.riik.ee/producer/rr");
                            clazz.Viga = metaViga.NewEntity<RRExtDocumentDataResponse.IsikudType.IsikType.VeadType.IVigaType>();
                            if ((Reader.IsEmptyElement == false)) {
                                Reader.ReadStartElement("viga");
                                metaViga.NewSerializer(clazz.Viga).ReadXml(Reader);
                                Reader.ReadEndElement();
                            }
                            else {
                                Reader.Skip();
                            }
                        }
                        else {
                            throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga", Reader.LocalName);
                        }
                    }
                    
                    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRExtDocumentDataResponse.IsikudType.IsikType.VeadType.VigaType))]
                    public class VigaTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
                        
                        protected RRExtDocumentDataResponse.IsikudType.IsikType.VeadType.IVigaType clazz;
                        
                        public VigaTypeSerializer(RRExtDocumentDataResponse.IsikudType.IsikType.VeadType.IVigaType clazz) {
                            this.clazz = clazz;
                        }
                        
                        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                            base.WriteXml(Writer);
                            Writer.WriteStartElement("kood");
                            if (clazz.Kood!=null) {
                                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kood))).ToString());
                            }
                            else {
                                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kood");
                            }
                            Writer.WriteEndElement();
                            Writer.WriteStartElement("tekst");
                            if (clazz.Tekst!=null) {
                                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tekst))).ToString());
                            }
                            else {
                                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Tekst");
                            }
                            Writer.WriteEndElement();
                        }
                        
                        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                            base.ReadXml(Reader);
                            if (Reader.LocalName=="kood") {
                                if (Reader.IsElementNil()) {
                                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga>kood");
                                }
                                clazz.Kood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kood")).Value;
                            }
                            else {
                                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga>kood", Reader.LocalName);
                            }
                            if (Reader.LocalName=="tekst") {
                                if (Reader.IsElementNil()) {
                                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga>tekst");
                                }
                                clazz.Tekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tekst")).Value;
                            }
                            else {
                                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>>>RRExtDocumentDataResponse>Isikud>Isik>vead>viga>tekst", Reader.LocalName);
                            }
                        }
                    }
                }
            }
        }
    }
}
